<?php

namespace App\Events;

use App\Services\OrderService;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderPayed
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $orderService;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(OrderService $orderService)
    {
        //如果需要可以在事件中注入逻辑Service 或者是逻辑模型，这样就可以把逻辑代码定义在Service 中或者是模型中，job handle 中只是一个Service 或者是模型的方法调用
        //这样就不用进行队列的重启了。
        $this->orderService = $orderService;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
